import React, { Component } from 'react';
import ReactDom from 'react-dom';
import util from "@/common/util";
import turnplate from "@/common/turnplate";
import layer from "@/common/layer";
import Rate from '@/Components/rate';
import DDView from '@/Components/ddview';
import InlinePicker from '@/Components/inlinepicker';
import ReactSwiper from 'reactjs-swiper';
import axios from 'axios';
import { relative } from 'path';
import jquery from 'jquery';


class Declarsystem extends Component {
    constructor(props) {
        super(props);
        this.state = {
            identity: -1
        }
    }

    componentDidMount() {
        this.setState({ identity: localStorage.getItem("identity") })
    }

    async toggle() {
        localStorage.clear()
        window.location.href = `./declarlogin.html`
    }

    // sale
    async declar() {
        if (this.state.identity == 1 || this.state.identity == 3) {
            window.location.href = `./declarv3.html`
        } else {
            jquery(".noauth").show().fadeOut(2000)
        }
    }
    async sale() {
        if (this.state.identity == 1 || this.state.identity == 3) {
            window.location.href = `./defbsale.html`
        } else {
            jquery(".noauth").show().fadeOut(2000)
        }
    }
    // bus
    async bus() {
        if (this.state.identity == 0 || this.state.identity == 4) {
            window.location.href = `./defbbus.html`
        } else {
            jquery(".noauth").show().fadeOut(2000)
        }
    }
    // boss
    async boss() {
        if (this.state.identity == 2 || this.state.identity == 3 || this.state.identity == 4) {
            window.location.href = `./defbboss.html`
        } else {
            jquery(".noauth").show().fadeOut(3000)
        }
    }

    render() {
        return (
            <div>
                <div className="tip">
                    <i></i>
                    <p>所有上传材料均为基础材料，</p>
                    <p>请销售人员注意收集完整材料。</p>
                </div>
                <div className="noauth">
                    不具备该权限！
                </div>
                <div id="system" style={{ position: 'relative', textAlign: 'center' }}>
                    <a href="#" className="enterdec" onClick={this.declar.bind(this)}>报单入口<i></i></a>
                    <a href="#" className="enterfeedback" onClick={this.sale.bind(this)}>反馈给销售<i></i></a>
                    <a href="#" className="enterfeedback" onClick={this.bus.bind(this)}>反馈给渠道<i></i></a>
                    <a href="#" className="enterfeedback" onClick={this.boss.bind(this)}>BOSS查看<i></i></a>
                    <a href="#" className="toggle" onClick={this.toggle.bind(this)}>切换账号 >></a>
                    <img src="/assets/wechat/salebackground.png" alt="" />
                </div>

            </div>
        )
    }
}
ReactDom.render(<Declarsystem />, document.getElementById("app"));